package elev.sim;

import com.kitfox.svg.SVGCache;
import com.kitfox.svg.SVGUniverse;
import com.kitfox.svg.app.beans.SVGPanel;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Główne okno.
 *
 * @author cmos
 */
public class GUI extends javax.swing.JFrame {

    Log log;
    LampSwitcher ls;
    List<SVGPanel> allPanels;
    Kontroler kontroler = new Kontroler();
    Statystyki statystyki;

    /**
     * Creates new form GUI.
     */
    public GUI() {
        try {
            log = new Log();
            ls = new LampSwitcher();
            statystyki = new Statystyki();
            Statystyki.zerujStatystyki();

            initComponents();
            allPanels = new ArrayList<>();

            allPanels.add(e11);
            allPanels.add(e12);
            allPanels.add(e13);
            allPanels.add(e14);
            allPanels.add(e15);
            allPanels.add(e16);
            allPanels.add(e17);
            allPanels.add(e18);
            allPanels.add(e21);
            allPanels.add(e22);
            allPanels.add(e23);
            allPanels.add(e24);
            allPanels.add(e24);
            allPanels.add(e25);
            allPanels.add(e26);
            allPanels.add(e27);
            allPanels.add(e28);

            SVGUniverse svgUniverse = SVGCache.getSVGUniverse();

            SVGUniverse e11u = svgUniverse.duplicate();
            SVGUniverse e12u = svgUniverse.duplicate();
            SVGUniverse e13u = svgUniverse.duplicate();
            SVGUniverse e14u = svgUniverse.duplicate();
            SVGUniverse e15u = svgUniverse.duplicate();
            SVGUniverse e16u = svgUniverse.duplicate();
            SVGUniverse e17u = svgUniverse.duplicate();
            SVGUniverse e18u = svgUniverse.duplicate();
            SVGUniverse e21u = svgUniverse.duplicate();
            SVGUniverse e22u = svgUniverse.duplicate();
            SVGUniverse e23u = svgUniverse.duplicate();
            SVGUniverse e24u = svgUniverse.duplicate();
            SVGUniverse e25u = svgUniverse.duplicate();
            SVGUniverse e26u = svgUniverse.duplicate();
            SVGUniverse e27u = svgUniverse.duplicate();
            SVGUniverse e28u = svgUniverse.duplicate();

            URI e11uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e12uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e13uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e14uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e15uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e16uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e17uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e18uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e21uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e22uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e23uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e24uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e25uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e26uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e27uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));
            URI e28uri = svgUniverse.loadSVG(getClass().getClassLoader().getResource("elev/sim/resources/ball.svg"));

            e11.setSvgUniverse(e11u);
            e12.setSvgUniverse(e12u);
            e13.setSvgUniverse(e13u);
            e14.setSvgUniverse(e14u);
            e15.setSvgUniverse(e15u);
            e16.setSvgUniverse(e16u);
            e17.setSvgUniverse(e17u);
            e18.setSvgUniverse(e18u);
            e21.setSvgUniverse(e21u);
            e22.setSvgUniverse(e22u);
            e23.setSvgUniverse(e23u);
            e24.setSvgUniverse(e24u);
            e25.setSvgUniverse(e25u);
            e26.setSvgUniverse(e26u);
            e27.setSvgUniverse(e27u);
            e28.setSvgUniverse(e28u);

            e11.setSvgURI(e11uri);
            e12.setSvgURI(e12uri);
            e13.setSvgURI(e13uri);
            e14.setSvgURI(e14uri);
            e15.setSvgURI(e15uri);
            e16.setSvgURI(e16uri);
            e17.setSvgURI(e17uri);
            e18.setSvgURI(e18uri);
            e21.setSvgURI(e21uri);
            e22.setSvgURI(e22uri);
            e23.setSvgURI(e23uri);
            e24.setSvgURI(e24uri);
            e25.setSvgURI(e25uri);
            e26.setSvgURI(e26uri);
            e27.setSvgURI(e27uri);
            e28.setSvgURI(e28uri);

            ustawieniaPoczatkowe();
        } catch (IOException | ClassNotFoundException ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        buttonGroup1 = new javax.swing.ButtonGroup();
        jSeparator1 = new javax.swing.JSeparator();
        jTab = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jSpinner1 = new javax.swing.JSpinner();
        jSpinner2 = new javax.swing.JSpinner();
        jSpinner3 = new javax.swing.JSpinner();
        jPanel7 = new javax.swing.JPanel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jRadioButton3 = new javax.swing.JRadioButton();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jSeparator2 = new javax.swing.JSeparator();
        jPanel10 = new javax.swing.JPanel();
        jLabel26 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jCheckBox2 = new javax.swing.JCheckBox();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        jComboBox3 = new javax.swing.JComboBox();
        jComboBox4 = new javax.swing.JComboBox();
        jComboBox5 = new javax.swing.JComboBox();
        jComboBox6 = new javax.swing.JComboBox();
        jComboBox7 = new javax.swing.JComboBox();
        jComboBox8 = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        e11 = new com.kitfox.svg.app.beans.SVGPanel();
        e12 = new com.kitfox.svg.app.beans.SVGPanel();
        e13 = new com.kitfox.svg.app.beans.SVGPanel();
        e14 = new com.kitfox.svg.app.beans.SVGPanel();
        e15 = new com.kitfox.svg.app.beans.SVGPanel();
        e16 = new com.kitfox.svg.app.beans.SVGPanel();
        e17 = new com.kitfox.svg.app.beans.SVGPanel();
        e18 = new com.kitfox.svg.app.beans.SVGPanel();
        e21 = new com.kitfox.svg.app.beans.SVGPanel();
        e22 = new com.kitfox.svg.app.beans.SVGPanel();
        e23 = new com.kitfox.svg.app.beans.SVGPanel();
        e24 = new com.kitfox.svg.app.beans.SVGPanel();
        e25 = new com.kitfox.svg.app.beans.SVGPanel();
        e26 = new com.kitfox.svg.app.beans.SVGPanel();
        e27 = new com.kitfox.svg.app.beans.SVGPanel();
        e28 = new com.kitfox.svg.app.beans.SVGPanel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jToggleButton1 = new javax.swing.JToggleButton();
        jButton3 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Elevator Simulator");
        setName("Form");
        getContentPane().setLayout(new java.awt.GridBagLayout());

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator1.setName("jSeparator1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 10;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(60, 0, 60, 0);
        getContentPane().add(jSeparator1, gridBagConstraints);

        jTab.setName("jTab");

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel3.setName("jPanel3");
        jPanel3.setLayout(new java.awt.GridBagLayout());

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Stałe", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black));
        jPanel6.setName("Stałe");
        java.awt.GridBagLayout jPanel6Layout = new java.awt.GridBagLayout();
        jPanel6Layout.columnWidths = new int[] {0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0};
        jPanel6Layout.rowHeights = new int[] {0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0};
        jPanel6.setLayout(jPanel6Layout);

        jLabel23.setText("Czas przejazdu pomiędzy piętrami [s]");
        jLabel23.setName("jLabel23");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 0, 0);
        jPanel6.add(jLabel23, gridBagConstraints);

        jLabel24.setText("Czas ładowania osób na piętrze [s]");
        jLabel24.setName("jLabel24");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 0, 0);
        jPanel6.add(jLabel24, gridBagConstraints);

        jLabel25.setText("Pojemność windy [osób]");
        jLabel25.setName("jLabel25");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 0, 0);
        jPanel6.add(jLabel25, gridBagConstraints);

        jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(0), null, Integer.valueOf(1)));
        jSpinner1.setName("jSpinner1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 0.2;
        jPanel6.add(jSpinner1, gridBagConstraints);

        jSpinner2.setName("jSpinner2");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 0.2;
        jPanel6.add(jSpinner2, gridBagConstraints);

        jSpinner3.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(8), Integer.valueOf(1), null, Integer.valueOf(1)));
        jSpinner3.setName("jSpinner3");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 0.2;
        jPanel6.add(jSpinner3, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel3.add(jPanel6, gridBagConstraints);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Algorytmy"));
        jPanel7.setName("jPanel7");
        java.awt.GridBagLayout jPanel7Layout = new java.awt.GridBagLayout();
        jPanel7Layout.columnWidths = new int[] {0};
        jPanel7Layout.rowHeights = new int[] {0, 10, 0, 10, 0, 10, 0};
        jPanel7.setLayout(jPanel7Layout);

        buttonGroup1.add(jRadioButton1);
        jRadioButton1.setSelected(true);
        jRadioButton1.setText("Algorytm 1");
        jRadioButton1.setName("jRadioButton1");
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 0);
        jPanel7.add(jRadioButton1, gridBagConstraints);

        buttonGroup1.add(jRadioButton2);
        jRadioButton2.setText("Algorytm 2");
        jRadioButton2.setName("jRadioButton2");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 0);
        jPanel7.add(jRadioButton2, gridBagConstraints);

        buttonGroup1.add(jRadioButton3);
        jRadioButton3.setText("Algorytm 3");
        jRadioButton3.setName("jRadioButton3");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 0);
        jPanel7.add(jRadioButton3, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel3.add(jPanel7, gridBagConstraints);

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Statystyki"));
        jPanel8.setName("jPanel8");
        jPanel8.setLayout(new java.awt.GridBagLayout());

        jScrollPane2.setName("jScrollPane2");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Czas pracy windy [s]", "", ""},
                {"Przejechane piętra", "", ""},
                {"Przewiezione osoby", "", ""},
                {"Osobopiętra", "", ""}
            },
            new String [] {
                "Nazwa", "Winda 1", "Winda 2"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jTable1.setName("jTable1");
        jScrollPane2.setViewportView(jTable1);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel8.add(jScrollPane2, gridBagConstraints);

        jScrollPane3.setName("jScrollPane3");

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Czas oczekiwania pasażera (min/avg/max)", null},
                {"Czas obsługi pasażera (min/avg/max)", null}
            },
            new String [] {
                "Nazwa", "Wartość"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setName("jTable2");
        jScrollPane3.setViewportView(jTable2);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipady = 3;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel8.add(jScrollPane3, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.2;
        jPanel3.add(jPanel8, gridBagConstraints);

        jTab.addTab("Ustawienia", jPanel3);
        jPanel3.getAccessibleContext().setAccessibleName("Ustawienia");

        jPanel5.setName("jPanel5");
        jPanel5.setLayout(new java.awt.GridBagLayout());

        jScrollPane1.setName("jScrollPane1");

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setName("jTextArea1");
        jScrollPane1.setViewportView(jTextArea1);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 4.0;
        gridBagConstraints.insets = new java.awt.Insets(20, 20, 10, 20);
        jPanel5.add(jScrollPane1, gridBagConstraints);

        jButton1.setText("Zapisz do pliku");
        jButton1.setName("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(25, 0, 25, 0);
        jPanel5.add(jButton1, gridBagConstraints);

        jTab.addTab("Log", jPanel5);
        jPanel5.getAccessibleContext().setAccessibleName("Log");

        jPanel9.setName("jPanel9");
        jPanel9.setLayout(new java.awt.GridBagLayout());

        jScrollPane4.setMaximumSize(new java.awt.Dimension(500, 800));
        jScrollPane4.setName("jScrollPane4");

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                { new Integer(1), "", null},
                { new Integer(2), null, null},
                { new Integer(3), null, null},
                { new Integer(4), null, null},
                { new Integer(5), null, null},
                { new Integer(6), null, null},
                { new Integer(7), null, null},
                { new Integer(8), null, null}
            },
            new String [] {
                "Piętro", "Pasażerowie na piętro", "Razem oczekujących"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable3.setName("jTable3");
        jScrollPane4.setViewportView(jTable3);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 431;
        gridBagConstraints.ipady = 396;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        jPanel9.add(jScrollPane4, gridBagConstraints);

        jSeparator2.setName("jSeparator2");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipady = 5;
        gridBagConstraints.weightx = 0.2;
        gridBagConstraints.weighty = 0.1;
        jPanel9.add(jSeparator2, gridBagConstraints);

        jPanel10.setName("jPanel10");

        jLabel26.setText("jLabel26");
        jLabel26.setName("jLabel26");

        org.jdesktop.layout.GroupLayout jPanel10Layout = new org.jdesktop.layout.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 59, Short.MAX_VALUE)
            .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel10Layout.createSequentialGroup()
                    .add(0, 0, Short.MAX_VALUE)
                    .add(jLabel26)
                    .add(0, 0, Short.MAX_VALUE)))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 15, Short.MAX_VALUE)
            .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel10Layout.createSequentialGroup()
                    .add(0, 0, Short.MAX_VALUE)
                    .add(jLabel26)
                    .add(0, 0, Short.MAX_VALUE)))
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 2;
        jPanel9.add(jPanel10, gridBagConstraints);

        jTab.addTab("Rozkład pasażerów", jPanel9);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 15;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        gridBagConstraints.weightx = 0.7;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(3, 0, 3, 0);
        getContentPane().add(jTab, gridBagConstraints);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setName("jPanel1");
        jPanel1.setLayout(new java.awt.GridBagLayout());

        jPanel2.setName("jPanel2");
        java.awt.GridBagLayout jPanel2Layout1 = new java.awt.GridBagLayout();
        jPanel2Layout1.columnWidths = new int[] {0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0, 10, 0};
        jPanel2Layout1.rowHeights = new int[] {0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0};
        jPanel2.setLayout(jPanel2Layout1);

        jLabel1.setText("Piętro");
        jLabel1.setName("jLabel1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        jPanel2.add(jLabel1, gridBagConstraints);

        jLabel2.setText("1");
        jLabel2.setName("jLabel2");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        jPanel2.add(jLabel2, gridBagConstraints);

        jLabel3.setText("2");
        jLabel3.setName("jLabel3");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        jPanel2.add(jLabel3, gridBagConstraints);

        jLabel4.setText("3");
        jLabel4.setName("jLabel4");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 12;
        jPanel2.add(jLabel4, gridBagConstraints);

        jLabel5.setText("4");
        jLabel5.setName("jLabel5");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 16;
        jPanel2.add(jLabel5, gridBagConstraints);

        jLabel6.setText("5");
        jLabel6.setName("jLabel6");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 20;
        jPanel2.add(jLabel6, gridBagConstraints);

        jLabel7.setText("6");
        jLabel7.setName("jLabel7");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 24;
        jPanel2.add(jLabel7, gridBagConstraints);

        jLabel8.setText("7");
        jLabel8.setName("jLabel8");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 28;
        jPanel2.add(jLabel8, gridBagConstraints);

        jLabel9.setText("8");
        jLabel9.setName("jLabel9");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 32;
        jPanel2.add(jLabel9, gridBagConstraints);

        jLabel10.setText("Winda 1");
        jLabel10.setName("jLabel10");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        jPanel2.add(jLabel10, gridBagConstraints);

        jLabel11.setText("Winda 2");
        jLabel11.setName("jLabel11");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 0;
        jPanel2.add(jLabel11, gridBagConstraints);

        jLabel12.setText("Dodaj pasażerów");
        jLabel12.setName("jLabel12");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 5;
        jPanel2.add(jLabel12, gridBagConstraints);

        jLabel13.setText("Razem oczekujących");
        jLabel13.setName("jLabel13");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 0;
        jPanel2.add(jLabel13, gridBagConstraints);

        jLabel14.setText("Włącz");
        jLabel14.setName("jLabel14");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 36;
        jPanel2.add(jLabel14, gridBagConstraints);

        jCheckBox2.setSelected(true);
        jCheckBox2.setName("jCheckBox2");
        jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 36;
        jPanel2.add(jCheckBox2, gridBagConstraints);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "2", "3", "4", "5", "6", "7", "8" }));
        jComboBox1.setName("jComboBox1");
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 4;
        jPanel2.add(jComboBox1, gridBagConstraints);

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "1", "3", "4", "5", "6", "7", "8" }));
        jComboBox2.setName("jComboBox2");
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 8;
        jPanel2.add(jComboBox2, gridBagConstraints);

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "1", "2", "4", "5", "6", "7", "8" }));
        jComboBox3.setName("jComboBox3");
        jComboBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox3ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 12;
        jPanel2.add(jComboBox3, gridBagConstraints);

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "1", "2", "3", "5", "6", "7", "8" }));
        jComboBox4.setName("jComboBox4");
        jComboBox4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox4ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 16;
        jPanel2.add(jComboBox4, gridBagConstraints);

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "1", "2", "3", "4", "6", "7", "8" }));
        jComboBox5.setName("jComboBox5");
        jComboBox5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox5ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 20;
        jPanel2.add(jComboBox5, gridBagConstraints);

        jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "1", "2", "3", "4", "5", "7", "8" }));
        jComboBox6.setName("jComboBox6");
        jComboBox6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox6ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 24;
        jPanel2.add(jComboBox6, gridBagConstraints);

        jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "1", "2", "3", "4", "5", "6", "8" }));
        jComboBox7.setName("jComboBox7");
        jComboBox7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox7ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 28;
        jPanel2.add(jComboBox7, gridBagConstraints);

        jComboBox8.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wybierz piętro", "1", "2", "3", "4", "5", "6", "7" }));
        jComboBox8.setName("jComboBox8");
        jComboBox8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox8ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 32;
        jPanel2.add(jComboBox8, gridBagConstraints);

        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel15.setText("0");
        jLabel15.setToolTipText("<html>\n<body>\nNa piętro 2: <b>3</b><br/>\nNa piętro 5: <b>7</b><br/>\nRazem: <b>10</b>\n</body>\n</html>");
        jLabel15.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel15.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel15.setName("jLabel15");
        jLabel15.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel15, gridBagConstraints);

        jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel16.setText("0");
        jLabel16.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel16.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel16.setName("jLabel16");
        jLabel16.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel16, gridBagConstraints);

        jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel17.setText("0");
        jLabel17.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel17.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel17.setName("jLabel17");
        jLabel17.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel17, gridBagConstraints);

        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel18.setText("0");
        jLabel18.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel18.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel18.setName("jLabel18");
        jLabel18.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 16;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel18, gridBagConstraints);

        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel19.setText("0");
        jLabel19.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel19.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel19.setName("jLabel19");
        jLabel19.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel19, gridBagConstraints);

        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel20.setText("0");
        jLabel20.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel20.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel20.setName("jLabel20");
        jLabel20.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 24;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel20, gridBagConstraints);

        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel21.setText("0");
        jLabel21.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel21.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel21.setName("jLabel21");
        jLabel21.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 28;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel21, gridBagConstraints);

        jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel22.setText("0");
        jLabel22.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel22.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel22.setName("jLabel22");
        jLabel22.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 18;
        gridBagConstraints.gridy = 32;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel22, gridBagConstraints);

        jLabel29.setText("Dotychczas przewiezionych");
        jLabel29.setName("jLabel29");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 0;
        jPanel2.add(jLabel29, gridBagConstraints);

        jLabel30.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel30.setText("0");
        jLabel30.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel30.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel30.setName("jLabel30");
        jLabel30.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel30, gridBagConstraints);

        jLabel31.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel31.setText("0");
        jLabel31.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel31.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel31.setName("jLabel31");
        jLabel31.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel31, gridBagConstraints);

        jLabel32.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel32.setText("0");
        jLabel32.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel32.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel32.setName("jLabel32");
        jLabel32.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel32, gridBagConstraints);

        jLabel33.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel33.setText("0");
        jLabel33.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel33.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel33.setName("jLabel33");
        jLabel33.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 16;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel33, gridBagConstraints);

        jLabel34.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel34.setText("0");
        jLabel34.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel34.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel34.setName("jLabel34");
        jLabel34.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel34, gridBagConstraints);

        jLabel35.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel35.setText("0");
        jLabel35.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel35.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel35.setName("jLabel35");
        jLabel35.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 24;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel35, gridBagConstraints);

        jLabel36.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel36.setText("0");
        jLabel36.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel36.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel36.setName("jLabel36");
        jLabel36.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 28;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel36, gridBagConstraints);

        jLabel37.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel37.setText("0");
        jLabel37.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel37.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel37.setName("jLabel37");
        jLabel37.setOpaque(true);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 22;
        gridBagConstraints.gridy = 32;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        jPanel2.add(jLabel37, gridBagConstraints);

        e11.setAntiAlias(true);
        e11.setMinimumSize(new java.awt.Dimension(25, 25));
        e11.setName("e11");
        e11.setPreferredSize(new java.awt.Dimension(50, 50));
        e11.setScaleToFit(true);

        org.jdesktop.layout.GroupLayout e11Layout = new org.jdesktop.layout.GroupLayout(e11);
        e11.setLayout(e11Layout);
        e11Layout.setHorizontalGroup(
            e11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e11Layout.setVerticalGroup(
            e11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e11, gridBagConstraints);

        e12.setAntiAlias(true);
        e12.setMinimumSize(new java.awt.Dimension(25, 25));
        e12.setName("e12");
        e12.setPreferredSize(new java.awt.Dimension(50, 50));
        e12.setScaleToFit(true);

        org.jdesktop.layout.GroupLayout e12Layout = new org.jdesktop.layout.GroupLayout(e12);
        e12.setLayout(e12Layout);
        e12Layout.setHorizontalGroup(
            e12Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e12Layout.setVerticalGroup(
            e12Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e12, gridBagConstraints);

        e13.setAntiAlias(true);
        e13.setMinimumSize(new java.awt.Dimension(25, 25));
        e13.setName("e13");
        e13.setPreferredSize(new java.awt.Dimension(50, 50));
        e13.setScaleToFit(true);
        try {
            e13.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e13Layout = new org.jdesktop.layout.GroupLayout(e13);
        e13.setLayout(e13Layout);
        e13Layout.setHorizontalGroup(
            e13Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e13Layout.setVerticalGroup(
            e13Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e13, gridBagConstraints);

        e14.setAntiAlias(true);
        e14.setMinimumSize(new java.awt.Dimension(25, 25));
        e14.setName("e14");
        e14.setPreferredSize(new java.awt.Dimension(50, 50));
        e14.setScaleToFit(true);
        try {
            e14.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e14Layout = new org.jdesktop.layout.GroupLayout(e14);
        e14.setLayout(e14Layout);
        e14Layout.setHorizontalGroup(
            e14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e14Layout.setVerticalGroup(
            e14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 16;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e14, gridBagConstraints);

        e15.setAntiAlias(true);
        e15.setMinimumSize(new java.awt.Dimension(25, 25));
        e15.setName("e15");
        e15.setPreferredSize(new java.awt.Dimension(50, 50));
        e15.setScaleToFit(true);
        try {
            e15.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e15Layout = new org.jdesktop.layout.GroupLayout(e15);
        e15.setLayout(e15Layout);
        e15Layout.setHorizontalGroup(
            e15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e15Layout.setVerticalGroup(
            e15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e15, gridBagConstraints);

        e16.setAntiAlias(true);
        e16.setMinimumSize(new java.awt.Dimension(25, 25));
        e16.setName("e16");
        e16.setPreferredSize(new java.awt.Dimension(50, 50));
        e16.setScaleToFit(true);
        try {
            e16.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e16Layout = new org.jdesktop.layout.GroupLayout(e16);
        e16.setLayout(e16Layout);
        e16Layout.setHorizontalGroup(
            e16Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e16Layout.setVerticalGroup(
            e16Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 24;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e16, gridBagConstraints);

        e17.setAntiAlias(true);
        e17.setMinimumSize(new java.awt.Dimension(25, 25));
        e17.setName("e17");
        e17.setPreferredSize(new java.awt.Dimension(50, 50));
        e17.setScaleToFit(true);
        try {
            e17.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e17Layout = new org.jdesktop.layout.GroupLayout(e17);
        e17.setLayout(e17Layout);
        e17Layout.setHorizontalGroup(
            e17Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e17Layout.setVerticalGroup(
            e17Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 28;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e17, gridBagConstraints);

        e18.setAntiAlias(true);
        e18.setMinimumSize(new java.awt.Dimension(25, 25));
        e18.setName("e18");
        e18.setPreferredSize(new java.awt.Dimension(50, 50));
        e18.setScaleToFit(true);
        try {
            e18.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e18Layout = new org.jdesktop.layout.GroupLayout(e18);
        e18.setLayout(e18Layout);
        e18Layout.setHorizontalGroup(
            e18Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e18Layout.setVerticalGroup(
            e18Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 32;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e18, gridBagConstraints);

        e21.setAntiAlias(true);
        e21.setMinimumSize(new java.awt.Dimension(25, 25));
        e21.setName("e21");
        e21.setPreferredSize(new java.awt.Dimension(50, 50));
        e21.setScaleToFit(true);
        try {
            e21.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e21Layout = new org.jdesktop.layout.GroupLayout(e21);
        e21.setLayout(e21Layout);
        e21Layout.setHorizontalGroup(
            e21Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e21Layout.setVerticalGroup(
            e21Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e21, gridBagConstraints);

        e22.setAntiAlias(true);
        e22.setMinimumSize(new java.awt.Dimension(25, 25));
        e22.setName("e22");
        e22.setPreferredSize(new java.awt.Dimension(50, 50));
        e22.setScaleToFit(true);
        try {
            e22.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e22Layout = new org.jdesktop.layout.GroupLayout(e22);
        e22.setLayout(e22Layout);
        e22Layout.setHorizontalGroup(
            e22Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e22Layout.setVerticalGroup(
            e22Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e22, gridBagConstraints);

        e23.setAntiAlias(true);
        e23.setMinimumSize(new java.awt.Dimension(25, 25));
        e23.setName("e23");
        e23.setPreferredSize(new java.awt.Dimension(50, 50));
        e23.setScaleToFit(true);
        try {
            e23.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e23Layout = new org.jdesktop.layout.GroupLayout(e23);
        e23.setLayout(e23Layout);
        e23Layout.setHorizontalGroup(
            e23Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e23Layout.setVerticalGroup(
            e23Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e23, gridBagConstraints);

        e24.setAntiAlias(true);
        e24.setMinimumSize(new java.awt.Dimension(25, 25));
        e24.setName("e24");
        e24.setPreferredSize(new java.awt.Dimension(50, 50));
        e24.setScaleToFit(true);
        try {
            e24.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e24Layout = new org.jdesktop.layout.GroupLayout(e24);
        e24.setLayout(e24Layout);
        e24Layout.setHorizontalGroup(
            e24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e24Layout.setVerticalGroup(
            e24Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 16;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e24, gridBagConstraints);

        e25.setAntiAlias(true);
        e25.setMinimumSize(new java.awt.Dimension(25, 25));
        e25.setName("e25");
        e25.setPreferredSize(new java.awt.Dimension(50, 50));
        e25.setScaleToFit(true);
        try {
            e25.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e25Layout = new org.jdesktop.layout.GroupLayout(e25);
        e25.setLayout(e25Layout);
        e25Layout.setHorizontalGroup(
            e25Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e25Layout.setVerticalGroup(
            e25Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e25, gridBagConstraints);

        e26.setAntiAlias(true);
        e26.setMinimumSize(new java.awt.Dimension(25, 25));
        e26.setName("e26");
        e26.setPreferredSize(new java.awt.Dimension(50, 50));
        e26.setScaleToFit(true);
        try {
            e26.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e26Layout = new org.jdesktop.layout.GroupLayout(e26);
        e26.setLayout(e26Layout);
        e26Layout.setHorizontalGroup(
            e26Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e26Layout.setVerticalGroup(
            e26Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 24;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e26, gridBagConstraints);

        e27.setAntiAlias(true);
        e27.setMinimumSize(new java.awt.Dimension(25, 25));
        e27.setName("e27");
        e27.setPreferredSize(new java.awt.Dimension(50, 50));
        e27.setScaleToFit(true);
        try {
            e27.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e27Layout = new org.jdesktop.layout.GroupLayout(e27);
        e27.setLayout(e27Layout);
        e27Layout.setHorizontalGroup(
            e27Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e27Layout.setVerticalGroup(
            e27Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 28;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e27, gridBagConstraints);

        e28.setAntiAlias(true);
        e28.setMinimumSize(new java.awt.Dimension(25, 25));
        e28.setName("e28");
        e28.setPreferredSize(new java.awt.Dimension(50, 50));
        e28.setScaleToFit(true);
        try {
            e28.setSvgResourcePath("/elev/sim/resources/ball.svg");
        } catch (com.kitfox.svg.SVGException e1) {
            e1.printStackTrace();
        }

        org.jdesktop.layout.GroupLayout e28Layout = new org.jdesktop.layout.GroupLayout(e28);
        e28.setLayout(e28Layout);
        e28Layout.setHorizontalGroup(
            e28Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );
        e28Layout.setVerticalGroup(
            e28Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 50, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 8;
        gridBagConstraints.gridy = 32;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        jPanel2.add(e28, gridBagConstraints);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton4.setEnabled(false);
        jButton4.setName("jButton4");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 4;
        jPanel2.add(jButton4, gridBagConstraints);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton5.setEnabled(false);
        jButton5.setName("jButton5");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 8;
        jPanel2.add(jButton5, gridBagConstraints);

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton6.setEnabled(false);
        jButton6.setName("jButton6");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 12;
        jPanel2.add(jButton6, gridBagConstraints);

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton7.setEnabled(false);
        jButton7.setName("jButton7");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 16;
        jPanel2.add(jButton7, gridBagConstraints);

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton8.setEnabled(false);
        jButton8.setName("jButton8");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 20;
        jPanel2.add(jButton8, gridBagConstraints);

        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton9.setEnabled(false);
        jButton9.setName("jButton9");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 24;
        jPanel2.add(jButton9, gridBagConstraints);

        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton10.setEnabled(false);
        jButton10.setName("jButton10");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 28;
        jPanel2.add(jButton10, gridBagConstraints);

        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/elev/sim/resources/add.png"))); // NOI18N
        jButton11.setEnabled(false);
        jButton11.setName("jButton11");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 32;
        jPanel2.add(jButton11, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(15, 15, 15, 15);
        jPanel1.add(jPanel2, gridBagConstraints);

        jPanel4.setName("jPanel4");
        jPanel4.setLayout(new java.awt.GridBagLayout());

        jToggleButton1.setText("Start / Stop");
        jToggleButton1.setName("jToggleButton1");
        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButton1ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 20);
        jPanel4.add(jToggleButton1, gridBagConstraints);

        jButton3.setText("Reset");
        jButton3.setName("jButton3");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 20);
        jPanel4.add(jButton3, gridBagConstraints);

        jButton2.setText("Wczytaj z pliku...");
        jButton2.setName("jButton2");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(0, 20, 0, 0);
        jPanel4.add(jButton2, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.1;
        jPanel1.add(jPanel4, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
        gridBagConstraints.weighty = 0.1;
        gridBagConstraints.insets = new java.awt.Insets(23, 2, 2, 2);
        getContentPane().add(jPanel1, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private static String getValue(String tag, Element element) {
        NodeList nodes = element.getElementsByTagName(tag).item(0).getChildNodes();
        Node node = (Node) nodes.item(0);
        return node.getNodeValue();
    }

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO wycztaj plik i odpal go DALEJ NIE DZIALA
        //Create a file chooser
        final JFileChooser fc = new JFileChooser();

//In response to a button click:
        int returnVal = fc.showOpenDialog(jButton2);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();

            int num = 0;
            int tim = 0;
            int siz = 0;
            int alg = 0;

            try {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                Document dom = builder.parse(file);

                Element docEle = dom.getDocumentElement();
                NodeList nl = docEle.getElementsByTagName("settings");

                Node node = nl.item(0);
                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    Element el = (Element) nl.item(0);

                    num = Integer.parseInt(getValue("numberOfElev", el));
                    tim = Integer.parseInt(getValue("stepTime", el));
                    siz = Integer.parseInt(getValue("size", el));
                    alg = Integer.parseInt(getValue("algorithm", el));
                }

                kontroler.resetujWindy();
                kontroler.uruchomWindy(num, siz);
                this.jSpinner1.setValue(tim);
                this.jSpinner3.setValue(siz);

                if (alg == 0) {
                    jRadioButton1.setSelected(true);
                } else if (alg == 1) {
                    jRadioButton2.setSelected(true);
                } else if (alg == 2) {
                    jRadioButton3.setSelected(true);
                }
//kod ma odjac z xmla jedno pietro!
                nl = docEle.getElementsByTagName("passenger");
                for (int i = 0; i < nl.getLength(); i++) {
                    node = nl.item(i);
                    if (node.getNodeType() == Node.ELEMENT_NODE) {
                        Element element = (Element) node;
                        kontroler.dodajWezwanie(
                                Integer.parseInt(getValue("start", element))-1,
                                Integer.parseInt(getValue("end", element))-1);
                        aktualizujOsoby();
                        //dodajDoWyswietlanychOczekujacych(jLabel30);
                    }
                }


            } catch (Exception e) {
                System.err.println(e);
                System.exit(0);
            }
        } else {
//            log.append("Open command cancelled by user." + newline);
        }

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            // XXX resetuj lampki
            ls.reset(allPanels);
            wyzerujOczekujacychiPrzewiezionych();
            //migajWindami();
            ustawieniaPoczatkowe();
            kontroler.resetujWindy();
//            migajWindami();
            //odblokuj GUI
            unlockGUI();
            jToggleButton1.setSelected(false);


        } catch (Exception ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed
        try {
            ls.switchElevator(allPanels, 1, Colors.RED);


        } catch (Exception ex) {
            Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (jCheckBox2.isSelected()) {
            ls.change(Colors.GREEN, e21);
            repaint();
        }
        //TODO najprowdopodobniej trzeba bedzie ustawic winde w tym moiejscu w logice!!!
    }//GEN-LAST:event_jCheckBox2ActionPerformed

    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
        if (isLocked()) {
            unlockGUI();
        } else {
            Log log = new Log();
            log.addMessage("jakas wiadomosc");
            System.out.println(log.toString());

            lockGUI();
            Watek w1 = new Watek();
            (new Thread(w1)).start();

        }

    }//GEN-LAST:event_jToggleButton1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(0));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(0, ktorePietro(jComboBox1));
        //powrót do domyślnego
        jComboBox1.setSelectedIndex(0);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(1));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(1, ktorePietro(jComboBox2));
        //powrót do domyślnego
        jComboBox2.setSelectedIndex(0);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(2));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(2, ktorePietro(jComboBox3));
        //powrót do domyślnego
        jComboBox3.setSelectedIndex(0);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(3));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(3, ktorePietro(jComboBox4));
        //powrót do domyślnego
        jComboBox4.setSelectedIndex(0);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(4));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(4, ktorePietro(jComboBox5));
        //powrót do domyślnego
        jComboBox5.setSelectedIndex(0);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(5));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(5, ktorePietro(jComboBox6));
        //powrót do domyślnego
        jComboBox6.setSelectedIndex(0);
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(6));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(6, ktorePietro(jComboBox7));
        //powrót do domyślnego
        jComboBox7.setSelectedIndex(0);
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        //dodanie do oczekujacych pasazerow na pietrze 1
        dodajDoWyswietlanychOczekujacych(getJLabel_oczekujaceOsoby(7));

        //dodaj do kolejki oraz 
        kontroler.dodajWezwanie(7, ktorePietro(jComboBox8));
        //powrót do domyślnego
        jComboBox8.setSelectedIndex(0);
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        if (jComboBox1.getSelectedIndex() != 0) {
            jButton4.setEnabled(true);
        } else {
            jButton4.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        if (jComboBox2.getSelectedIndex() != 0) {
            jButton5.setEnabled(true);
        } else {
            jButton5.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed
        if (jComboBox3.getSelectedIndex() != 0) {
            jButton6.setEnabled(true);
        } else {
            jButton6.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox3ActionPerformed

    private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox4ActionPerformed
        if (jComboBox4.getSelectedIndex() != 0) {
            jButton7.setEnabled(true);
        } else {
            jButton7.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox4ActionPerformed

    private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox5ActionPerformed
        if (jComboBox5.getSelectedIndex() != 0) {
            jButton8.setEnabled(true);
        } else {
            jButton8.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox5ActionPerformed

    private void jComboBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox6ActionPerformed
        if (jComboBox6.getSelectedIndex() != 0) {
            jButton9.setEnabled(true);
        } else {
            jButton9.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox6ActionPerformed

    private void jComboBox7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox7ActionPerformed
        if (jComboBox7.getSelectedIndex() != 0) {
            jButton10.setEnabled(true);
        } else {
            jButton10.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox7ActionPerformed

    private void jComboBox8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox8ActionPerformed
        if (jComboBox8.getSelectedIndex() != 0) {
            jButton11.setEnabled(true);
        } else {
            jButton11.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBox8ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO zapisz plik
        //Create a file chooser
        final JFileChooser fc = new JFileChooser();

//In response to a button click:
        int returnVal = fc.showSaveDialog(jButton1);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            //This is where a real application would open the file.
//            log.append("Opening: " + file.getName() + "." + newline);
        } else {
//            log.append("Open command cancelled by user." + newline);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;


                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new GUI().setVisible(true);
                // XXX poczatek programu
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private com.kitfox.svg.app.beans.SVGPanel e11;
    private com.kitfox.svg.app.beans.SVGPanel e12;
    private com.kitfox.svg.app.beans.SVGPanel e13;
    private com.kitfox.svg.app.beans.SVGPanel e14;
    private com.kitfox.svg.app.beans.SVGPanel e15;
    private com.kitfox.svg.app.beans.SVGPanel e16;
    private com.kitfox.svg.app.beans.SVGPanel e17;
    private com.kitfox.svg.app.beans.SVGPanel e18;
    private com.kitfox.svg.app.beans.SVGPanel e21;
    private com.kitfox.svg.app.beans.SVGPanel e22;
    private com.kitfox.svg.app.beans.SVGPanel e23;
    private com.kitfox.svg.app.beans.SVGPanel e24;
    private com.kitfox.svg.app.beans.SVGPanel e25;
    private com.kitfox.svg.app.beans.SVGPanel e26;
    private com.kitfox.svg.app.beans.SVGPanel e27;
    private com.kitfox.svg.app.beans.SVGPanel e28;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JComboBox jComboBox6;
    private javax.swing.JComboBox jComboBox7;
    private javax.swing.JComboBox jComboBox8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JSpinner jSpinner2;
    private javax.swing.JSpinner jSpinner3;
    private javax.swing.JTabbedPane jTab;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JToggleButton jToggleButton1;
    // End of variables declaration//GEN-END:variables

    private boolean isLocked() {
        if (//jCheckBox1.isEnabled() && 
                jCheckBox2.isEnabled()
                && jSpinner1.isEnabled() && jSpinner2.isEnabled()
                && jSpinner3.isEnabled()
                && jComboBox1.isEnabled() && jComboBox2.isEnabled() && jComboBox3.isEnabled()
                && jComboBox4.isEnabled() && jComboBox5.isEnabled() && jComboBox6.isEnabled()
                && jComboBox7.isEnabled() && jComboBox8.isEnabled()
                && jButton2.isEnabled()) {
            return false;
        } else {
            return true;
        }
    }

    private void lockGUI() {
//        jCheckBox1.setEnabled(false);
        jCheckBox2.setEnabled(false);
        jSpinner1.setEnabled(false);
        jSpinner2.setEnabled(false);
        jSpinner3.setEnabled(false);
        jComboBox1.setEnabled(false);
        jComboBox2.setEnabled(false);
        jComboBox3.setEnabled(false);
        jComboBox4.setEnabled(false);
        jComboBox5.setEnabled(false);
        jComboBox6.setEnabled(false);
        jComboBox7.setEnabled(false);
        jComboBox8.setEnabled(false);
        jButton2.setEnabled(false);
    }

    private void unlockGUI() {
//        jCheckBox1.setEnabled(true);
        jCheckBox2.setEnabled(true);
        jSpinner1.setEnabled(true);
        jSpinner2.setEnabled(true);
        jSpinner3.setEnabled(true);
        jComboBox1.setEnabled(true);
        jComboBox2.setEnabled(true);
        jComboBox3.setEnabled(true);
        jComboBox4.setEnabled(true);
        jComboBox5.setEnabled(true);
        jComboBox6.setEnabled(true);
        jComboBox7.setEnabled(true);
        jComboBox8.setEnabled(true);
        jButton2.setEnabled(true);
    }

    private int ktorePietro(JComboBox jCB) {
        ComboBoxModel model = jCB.getModel();
        String selectedItem = (String) model.getSelectedItem();
        Integer x = new Integer(selectedItem);
        return x - 1; //korekcja
    }

    /**
     * Ustaw światło windy na konkretne piętro wg kontrolera
     *
     * @throws Exception
     */
    public void migajWindami() throws Exception {
        int pietro;
        //wyzeruj cala winde, zapal jedna lampke
        if (Statystyki.isCzyUruchomionaWinda1()) {
            pietro = kontroler.getPietro(0);
            ls.switchElevator(allPanels, 0, Colors.RED);
            switch (pietro) {
                case 0:
                    ls.change(Colors.GREEN, e11);
                    break;
                case 1:
                    ls.change(Colors.GREEN, e12);
                    break;
                case 2:
                    ls.change(Colors.GREEN, e13);
                    break;
                case 3:
                    ls.change(Colors.GREEN, e14);
                    break;
                case 4:
                    ls.change(Colors.GREEN, e15);
                    break;
                case 5:
                    ls.change(Colors.GREEN, e16);
                    break;
                case 6:
                    ls.change(Colors.GREEN, e17);
                    break;
                case 7:
                    ls.change(Colors.GREEN, e18);
                    break;
            }
        }
        if (Statystyki.isCzyUruchomionaWinda2()) {
            pietro = kontroler.getPietro(1);
            ls.switchElevator(allPanels, 1, Colors.RED);
            switch (pietro) {
                case 0:
                    ls.change(Colors.GREEN, e21);
                    break;
                case 1:
                    ls.change(Colors.GREEN, e22);
                    break;
                case 2:
                    ls.change(Colors.GREEN, e23);
                    break;
                case 3:
                    ls.change(Colors.GREEN, e24);
                    break;
                case 4:
                    ls.change(Colors.GREEN, e25);
                    break;
                case 5:
                    ls.change(Colors.GREEN, e26);
                    break;
                case 6:
                    ls.change(Colors.GREEN, e27);
                    break;
                case 7:
                    ls.change(Colors.GREEN, e28);
                    break;
            }
        }

    }

    /**
     * Funkcja czekajaca n sekund
     *
     * @param n liczba sekund przez ktore system ma stac
     */
    public static void waiting(int n) {

        long t0, t1;

        t0 = System.currentTimeMillis();

        do {
            t1 = System.currentTimeMillis();
        } while ((t1 - t0) < (n * 1000));
    }

    private void wyzerujOczekujacychiPrzewiezionych() {

        jLabel15.setText("0");
        jLabel16.setText("0");
        jLabel17.setText("0");
        jLabel18.setText("0");
        jLabel19.setText("0");
        jLabel20.setText("0");
        jLabel21.setText("0");
        jLabel22.setText("0");
        jLabel30.setText("0");
        jLabel31.setText("0");
        jLabel32.setText("0");
        jLabel33.setText("0");
        jLabel34.setText("0");
        jLabel35.setText("0");
        jLabel36.setText("0");
        jLabel37.setText("0");
    }

    /**
     * Zmiana wartosci kontrolek osob oczekujacych na danym pietrze
     *
     */
    private void aktualizujOsoby() {
        int iloscPieter = 8;
        int osoby = 0;
        JLabel label;
        for (int i = 0; i < iloscPieter; i++) {
            //pobranie ilosci osob z pietra i
            osoby = kontroler.getOsobyTotalCount(i);
            label = getJLabel_oczekujaceOsoby(i);
            if (getLiczbaFromLabel(label) != osoby) {
                //zamiana wyswietlanej ilosci osob jezeli sie zmienila
                label.setText(String.valueOf(osoby));
                // label.updateUI();
            }
            label = getJLabel_przewiezioneOsoby(i);
            if (getLiczbaFromLabel(label) != kontroler.getPrzewiezioneOsoby(i)) {
                label.setText(String.valueOf(kontroler.getPrzewiezioneOsoby(i))); //korekta, przewiezione osoby sa o jedna za malo
                //  label.updateUI();
            }
        }
    }

    private String osoboPietra(int nrWindy) {
        ArrayList<Integer> przejechanePietra = Statystyki.getPrzejechanePietra();
        ArrayList<Integer> rozwiezioneOsoby = Statystyki.getRozwiezioneOsoby();
        if (przejechanePietra.get(nrWindy) == 0) {
            return "0";
        } else {
            double po = rozwiezioneOsoby.get(nrWindy).doubleValue();
            double pp = przejechanePietra.get(nrWindy).doubleValue();
            Double x = new Double(po / pp);
            return x.toString();
        }
    }

    private void aktualizujStaty() {
        /*
         * zakladka rozklad pasazerow
         */
        HashMap<Integer, String> osobyAll = kontroler.getOsobyAll();
        for (int i = 0; i < 8; i++) {
            jTable3.setValueAt(osobyAll.get(i), i, 1);
            jTable3.setValueAt(kontroler.getOsobyTotalCount(i), i, 2);
        }
        /*
         * tabelka gorna
         */
        ArrayList<Integer> przejechanePietra = Statystyki.getPrzejechanePietra();
        ArrayList<Integer> rozwiezioneOsoby = Statystyki.getRozwiezioneOsoby();

        //winda1
        jTable1.setValueAt(Statystyki.getCzasPrzebiegu(0), 0, 1);
        jTable1.setValueAt(przejechanePietra.get(0), 1, 1);
        jTable1.setValueAt(rozwiezioneOsoby.get(0), 2, 1);
        jTable1.setValueAt(osoboPietra(0), 3, 1);
        //winda2
        jTable1.setValueAt(Statystyki.getCzasPrzebiegu(1), 0, 2);
        jTable1.setValueAt(przejechanePietra.get(1), 1, 2);
        jTable1.setValueAt(rozwiezioneOsoby.get(1), 2, 2);
        jTable1.setValueAt(osoboPietra(1), 3, 2);
        /*
         * tabelka dolna
         */
        jTable2.setValueAt(Statystyki.getCzasOczekiwaniaFormatted(), 0, 1);
        jTable2.setValueAt(Statystyki.getCzasObslugiFormatted(), 1, 1);
    }

    public void dodajDoWyswietlanychOczekujacych(javax.swing.JLabel jLabel) {
        jLabel.setText(String.valueOf(getLiczbaFromLabel(jLabel) + 1));
    }

    /**
     * Usuniecie oczekujacego pasazera z wyswietlanych
     *
     * @param jLabel kontrolka z "Razem oczekujacych" ktora ustawiasz
     *
     */
    public void usunZWyswietlanychOczekujacych(javax.swing.JLabel jLabel) {
        jLabel.setText(String.valueOf(getLiczbaFromLabel(jLabel) - 1));
    }

    /**
     * Pobranie liczby oczekujacych pasazerow z kontrolki
     *
     * @param jLabel kontrolka z "Razem oczekujacych" ktora ustawiasz
     * @return
     */
    private int getLiczbaFromLabel(javax.swing.JLabel jLabel) {
        return Integer.parseInt(jLabel.getText());
    }

    /**
     * Pobranie kontrolki "razem oczekujacych" odpowiadajacej podanemu pietru
     *
     * @param jLabel kontrolka z "Razem oczekujacych" ktora ustawiasz
     * @return
     */
    private javax.swing.JLabel getJLabel_oczekujaceOsoby(int pietro) {
        switch (pietro) {

            case 0:
                return jLabel15;
            case 1:
                return jLabel16;
            case 2:
                return jLabel17;
            case 3:
                return jLabel18;
            case 4:
                return jLabel19;
            case 5:
                return jLabel20;
            case 6:
                return jLabel21;
            case 7:
                return jLabel22;
        }
        return null;
    }

    private javax.swing.JLabel getJLabel_przewiezioneOsoby(int pietro) {
        switch (pietro) {

            case 0:
                return jLabel30;
            case 1:
                return jLabel31;
            case 2:
                return jLabel32;
            case 3:
                return jLabel33;
            case 4:
                return jLabel34;
            case 5:
                return jLabel35;
            case 6:
                return jLabel36;
            case 7:
                return jLabel37;
        }
        return null;



    }

    private void ustawieniaPoczatkowe() {
        ls.reset(allPanels);
//            if (jCheckBox1.isSelected()){
        ls.change(Colors.GREEN, e18);
//            }
        if (jCheckBox2.isSelected()) {
            ls.change(Colors.GREEN, e21);
        }
    }

    public class Watek implements Runnable {

        @Override
        public void run() {
            try {
                //ile wind
                int iloscWind = 0;
//
                iloscWind++;
                //              }
                if (jCheckBox2.isSelected()) {
                    iloscWind++;
                }
                ls.reset(allPanels);
                //kontroler.uruchomWindy(iloscWind, 8);

                //zerowanie statystyk i pobieranie nowych
                Statystyki.zerujStatystyki();
                Statystyki.setCzasPrzejazduPomiedzyPietrami((Integer) jSpinner1.getValue());
                Statystyki.setCzyUruchomionaWinda1(true);
//                Statystyki.setCzyUruchomionaWinda1(jCheckBox1.isSelected());
                Statystyki.setCzyUruchomionaWinda2(jCheckBox2.isSelected());
                Statystyki.setNumerAlgorytmu(buttonGroup1.getSelection().getMnemonic());

                Statystyki.setPojemnoscWindy((Integer) jSpinner3.getValue());
                kontroler.uruchomWindy(iloscWind, Statystyki.getPojemnoscWindy());

                migajWindami();
                kontroler.rozdzielWezwania();
                //czas wykonania petli
                int czas = 0;

                while (isLocked() != false) {

                    kontroler.krok();
                    czas++;
                    //aktualizacja kontrolek z osobami oczekujacymi i przewiezionymi
                    aktualizujOsoby();
                    aktualizujStaty();
                    try {
                        //zielone kontrolki dla aktualnej pozycji windy
                        migajWindami();
                        //warunek stopu
                        if (kontroler.czyWszystkieRozwiezione() == true) {
                            break;
                        }

                        //petla wykonywana co sekunde
                        waiting(Statystyki.getCzasPrzejazduPomiedzyPietrami());
                        //aktualizowanie loga w kazdym kroku petli
                        jTextArea1.setText(log.toString());

                        //TODO podpiecie danych ze Statystyki do tej smesznej tabelki tutaj.
                    } catch (Exception ex) {
                        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }
                Log.koniecSesji();
                jTextArea1.setText(log.toString());
                //odblokowanie przyciskow na zakonczenie watku
                unlockGUI();
                System.out.println(statystyki.toString());
            } catch (Exception ex) {
                Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
